﻿using System;
using System.Collections.Generic;
using System.Linq;
using Infrastucture;

namespace TimeSplicerModule.DomainModels
{
    public class TeamModel : DomainObject
    {
        private Guid _teamGuid;
        private Guid _parentTeamGuid;
        private string _name;
        private string _acronym;
        private bool _isActive;
        private int _x;
        private int _y;
        private TeamModel _parentTeam;
        private List<TeamModel> _teams;


        public Guid TeamGuid
        {
            get { return _teamGuid; }
            set { SetProperty(ref _teamGuid, value); }
        }
        public Guid ParentTeamGuid
        {
            get { return _parentTeamGuid; }
            set { SetProperty(ref _parentTeamGuid, value); }
        }
        public string Name
        {
            get { return _name; }
            set { SetProperty(ref  _name, value); }
        }
        public string Acronym
        {
            get { return _acronym; }
            set { SetProperty(ref _acronym, value); }
        }
        public bool IsActive
        {
            get { return _isActive; }
            set { SetProperty(ref _isActive, value); }
        }
        public int X
        {
            get { return _x; }
            set { SetProperty(ref _x, value); }
        }
        public int Y
        {
            get { return _y; }
            set { SetProperty(ref _y, value); }
        }
        public TeamModel ParentTeam
        {
            get { return _parentTeam; }
            set { SetProperty(ref _parentTeam, value); }
        }
        public List<TeamModel> Teams
        {
            get { return _teams; }
            set 
            { 
                SetProperty(ref _teams, value);

                if (this.Teams != null)
                    this.ParentTeam = this.Teams.FirstOrDefault(x => x.TeamGuid == this.ParentTeamGuid);
            }
        }
    }
}
